package com.foreknow.demo5Exercise1;

/**
 * 1、定义一个点类Point，包含2个成员变量x、y分别表示x和y坐标
 * 2个构造器Point()和Point(intx0,y0),以及一个movePoint（int dx,int dy）方法实现点的位置移动
 * 创建两个Point对象p1、p2，分别调用movePoint方法后，打印p1和p2的坐标。
 */
public class Point {
    private int x;
    private int y;

    public Point() {

    }

    public Point(int x,int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public void movePoint(int dx, int dy) {
        this.x += dx;
        this.y += dy;
        System.out.println(dx);
        System.out.println(dy);
    }

    public static void main(String[] args) {

        Point p1 = new Point(13,12);
//        p1.setX(13);
//        p1.setY(12);
        System.out.println("p1.x = " + p1.getX());
        System.out.println("p1.y = " + p1.getY());
        p1.movePoint(6,7);

        Point p2 = new Point(14,13);
//        p2.setX(14);
//        p2.setY(13);
        System.out.println("p2.x = " + p2.getX());
        System.out.println("p2.y = " + p2.getY());
        p2.movePoint(4,5);
    }
}
